package adminTests;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

import java.util.concurrent.TimeUnit;
import java.util.Date;
import java.io.File;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.*;
import static org.openqa.selenium.OutputType.*;

public class LoginLogoutAdminTest {
	FirefoxDriver wd;

	@BeforeMethod
	public void setUp() throws Exception {
		wd = new FirefoxDriver();
		wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
	}

	@Test
	public void loginAdmin() {
//		wd.get("http://95.211.240.164:81/xadmin/");
		wd.get("http://testwmt.wdev.com.ua/xadmin/");
		wd.findElement(By.id("login")).click();
		wd.findElement(By.id("login")).clear();
		wd.findElement(By.id("login")).sendKeys("admin");
		wd.findElement(By.id("password")).click();
		wd.findElement(By.id("password")).clear();
		wd.findElement(By.id("password")).sendKeys("devpass");
// wd.findElement(By.xpath("//form[@id='formLogin']//button[.='Sign in']")).click();
// wd.findElement(By.xpath("//button[@type='submit']")).click();
		wd.findElement(By.xpath("//button")).click();

	}

	@AfterMethod
	public void tearDown() {
		wd.quit();
	}

	public static boolean isAlertPresent(FirefoxDriver wd) {
		try {
			wd.switchTo().alert();
			return true;
		} catch (NoAlertPresentException e) {
			return false;
		}
	}
}
